home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_05
/
saks
/
lns1a.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-08
|
3KB
|
137 lines
Listing 5 - member function definitions for lns using a single pointer
//
// lns1a.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
node *p = first;
while (p->next != 0 && p->number != n)
p = p->next;
if (p->number != n)
p = p->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf(" %4d", p->number);
}
Listing 5 - member function definitions for lns using a single pointer
//
// lns1a.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
node *p = first;
while (p->next != 0 && p->number != n)
p = p->next;
if (p->number != n)
p = p->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf(" %4d", p->number);
}
Listing 5 - member function definitions for lns using a single pointer
//
// lns1a.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
node *p = first;
while (p->next != 0 && p->number != n)
p = p->next;
if (p->number != n)
p = p->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf(" %4d", p->number);
}
Listing 5 - member function definitions for lns using a single pointer
//
// lns1a.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
node *p = first;
while (p->next != 0 && p->number != n)
p = p->next;
if (p->number != n)
p = p->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf(" %4d", p->number);
}